﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;

public partial class admin_AdminStatistics : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            bindExamAllNameList();
        }
    }
    private string getHtml()
    {

        DataTable dt_rank = Statistics.getAllExamName(ddlExamAllName.SelectedValue.ToString());
        DataTable dt_name = Statistics.getSchoolName(ddlExamAllName.SelectedValue.ToString());
        string html = "";
        StringBuilder htmlTemp = new StringBuilder();
        for (int i = 0; i < dt_name.Rows.Count; i++)
        {
            string schoolName = dt_name.Rows[i]["StudFrom"].ToString();
            htmlTemp.Append(@"<div class='am-tab-panel am-fade am-in am-active' id='"+schoolName+"'><div class='am-g am-margin-top' style='margin-top: 1px;'>");
            foreach (DataRow dr_rank in dt_rank.Rows)
            {
                //string emId = dr_emId["EmID"].ToString().Trim();
                //DataTable dt_rank = Exam.getRankNameByEmID(emId);
                //foreach (DataRow dr_rank in dt_rank.Rows)
                //{
                    htmlTemp.Append("<ul class='am-avg-sm-1 am-avg-md-3 am-margin am-padding am-text-center admin-content-list '>");
                    string emRankName = dr_rank["EmRankName"].ToString().Trim();
                    DataTable dt_success = Statistics.getApplyFinish(ddlExamAllName.SelectedValue.ToString(), emRankName, "2", schoolName);
                    DataTable dt_fail = Statistics.getApplyFinish(ddlExamAllName.SelectedValue.ToString(), emRankName, "1", schoolName);
                    string countSuccess = dt_success.Rows[0]["Count"].ToString();
                    string countFail = dt_fail.Rows[0]["Count"].ToString();
                    htmlTemp.Append("<li><a href='javascript:;' style='line-height:98px'>" + emRankName + "</a></li>");
                    htmlTemp.Append(@"<li><a href='javascript:;' class='am-text-success'><span class='am-icon-btn am-icon-briefcase'></span><br/>完成人数<br/>" + countSuccess + @"</a></li>
                    <li><a href='javascript:;' class='am-text-warning'><span class='am-icon-btn am-icon-recycle'></span><br/>未完成人数<br/>" + countFail + "</a></li>");

                    htmlTemp.Append("</ul>");                 
                //}

            }
            htmlTemp.Append("</div></div>");
            html += htmlTemp.ToString();
        }

        return html;
    }
    public string htmlSchoolList()
    {
        DataTable dt = Statistics.getSchoolName(ddlExamAllName.SelectedValue.ToString());
        StringBuilder sb = new StringBuilder();
        foreach (DataRow dr in dt.Rows)
        {
            string schoolName = dr["StudFrom"].ToString().Trim();
            sb.Append("<li><a href='#" + schoolName + "'>" + schoolName + "</a></li>");
        }
        return sb.ToString();
    }
    protected void lbRefurbish_Click(object sender, EventArgs e)
    {
        if (ddlExamAllName.SelectedValue != null)
        {
            lbSchool.Text = htmlSchoolList();
            lbHtml.Text = getHtml();
        }
    }
    private void bindExamAllNameList()
    {
        DataTable dt = Exam.ExamTime_GetTopList();
        BSUtility.BindListControl(ddlExamAllName, dt, "EmAllName", "TimeID");
    }

}